package com.ydj.framework.job;

import com.ydj.framework.module.init.entity.dao.FwInitVersionDao;
import com.ydj.framework.redis.ExtRedisTemplate;
import com.ydj.framework.task.BaseJob;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class KeepAliveJob extends BaseJob {

    @Autowired
    FwInitVersionDao dao;
    @Autowired
    ExtRedisTemplate redisTemplate;

    @Override
    protected String name() {
        return "Mysql心跳包";
    }

    @Override
    protected Boolean logEnable() {
        return false;
    }

    @Override
    protected boolean onlyRunAtMasterServer() {
        return false;
    }

    @Override
    public String cronExpress() {
//		%d=1，则出现下面时间
//		2021-04-12 14:37:00
//		2021-04-12 14:38:00
//		2021-04-12 14:39:00
//		2021-04-12 14:40:00
//		2021-04-12 14:41:00
//		2021-04-12 14:42:00
//		2021-04-12 14:43:00
//		2021-04-12 14:44:00
//		2021-04-12 14:45:00
//		2021-04-12 14:46:00
        return "0 0/1 * * * ? ";
    }

    @Override
    public void doExecuteInternal() throws Exception {
        dao.count();
        redisTemplate.opsForValue().get("rick");
    }
}
